<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Charset</title>
    <script src="/static/jQuery-1.11/jquery-1.11.3.min.js"></script>
    <script>
        $(function () {
            $('#username').blur(function () {
                //打印事件源
                //console.log(this)
                //获取用户输入的用户名
                var username = $(this).val();
                //拼接字符串
                var paramString = 'username=' + username;
                $.get('/checkUsername',paramString,function (data) {
                    $('#result').html(data.msg).css('color',data.success ? 'green' : 'red');
                });
            });
        });
    </script>
</head>
<body>
<span id="result"></span><br/>
用户名: <input type="text" name="username" id="username"><br/>
<input type="button" value="登录">
</body>
</html>